home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 November: Tool Chest / Dev.CD Nov 00 TC Disk 2.toast / pc / sample code / processes / howtohideyourapp / hidecalls.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-09-28  |  4.5 KB  |  113 lines

  1. /*    File:        HideCalls.h
  2.     
  3.     Description: 
  4.              This sample illustrates how the SetHideOnSwitch and GetHideOnSwitch
  5.             routines can be used to hide an application.  These routines were first
  6.             documented in Technote TN1102, "Mac OS 8".  On the world wide
  7.             web, documentation for these routines can be found at the address:
  8.             
  9.             http://developer.apple.com/technotes/tn/tn1102.html#processmgr
  10.             
  11.             This file contains constant and declarations necessary for using these
  12.             routines along with definitions for routines defined in the file HideCalls.c.
  13.  
  14.     Copyright: 
  15.             Copyright © 1999 by Apple Computer, Inc.
  16.             All rights reserved.
  17.     
  18.     Disclaimer:
  19.             You may incorporate this sample code into your applications without
  20.             restriction, though the sample code has been provided "AS IS" and the
  21.             responsibility for its operation is 100% yours.  However, what you are
  22.             not permitted to do is to redistribute the source as "DSC Sample Code"
  23.             after having made changes. If you're going to re-distribute the source,
  24.             we require that you make it clear in the source that the code was
  25.             descended from Apple Sample Code, but that you've made changes.
  26.     
  27.     Change History (most recent first):
  28.             12/6/1999 created
  29. */
  30.  
  31. #ifndef __HIDECALLS__
  32. #define __HIDECALLS__
  33.  
  34. #include <MacTypes.h>
  35. #include <ConditionalMacros.h>
  36. #include <Events.h>
  37. #include <Processes.h>
  38.  
  39.  
  40. /* gestaltHideLayerOnSwitchSupport is a bit defined in the
  41.     response returned by the gestaltOSAttr Gestalt selector.
  42.     If this bit is set, then you can use the routines defined
  43.     in this file.  */
  44. enum {
  45.     gestaltHideLayerOnSwitchSupport = 16
  46. };
  47.  
  48.  
  49. /* HideCallsExist returns true if the gestaltHideLayerOnSwitchSupport
  50.     bit is set in the response returned by the gestaltOSAttr Gestalt
  51.     selector.  If this routine returns true, then it is safe to call
  52.     SetHideOnSwitch and GetHideOnSwitch. */
  53. Boolean HideCallsExist(void);
  54.  
  55.  
  56. /* SetHideOnSwitch sets the 'hide on switch' global variable to
  57.     the value stored in setValue.  If the 'hide on switch' global
  58.     variable is true, then processes will be hidden every time
  59.     they are switched out by the process manager. */
  60. extern pascal void SetHideOnSwitch(Boolean setValue)
  61.       THREEWORDINLINE(0x3F3C, 0x006B, 0xA88F);
  62.  
  63. /* GetHideOnSwitch queries and returns the state of the
  64.     'hide on switch' global variable. */
  65. extern pascal Boolean GetHideOnSwitch(void)
  66.       THREEWORDINLINE(0x3F3C, 0x006C, 0xA88F);
  67.  
  68.  
  69.  
  70. /* HideMe is a routine you can use to hide your application on
  71.     demand.  Its functionality relies on the presence of the
  72.     SetHideOnSwitch routine and the process manager.  
  73.     
  74.     HideMe works by turning on the 'hide on switch' variable to
  75.     true, switching out its own process, and then turning off
  76.     the 'hide on switch' flag after its process has been switched
  77.     out.
  78.     
  79.     The following describes HideMe and it's support routines. */
  80.  
  81.  
  82. /* EventIdleProc is a routine your application defines and passes
  83.     to the HideMe routine.  The Process Manager switches processes
  84.     in and out of the foreground during calls to WaitNextEvent.  Because
  85.     of this, HideMe calls WaitNextEvent while it is waiting for a process
  86.     to be switched in or out of the forground.  Any events returned
  87.     during those times are passed back to your application through the
  88.     EventIdleProc you provide as a parameter to the HideMe routine.
  89.     
  90.     If your EventIdleProc returns any result code other than noErr,
  91.     HideMe will abort and return that error code.  */
  92. typedef OSStatus (*EventIdleProc)(EventRecord *ev);
  93.  
  94. /* SelectNextFrontProcess is a callback your application provides to the
  95.     HideMe routine.  After setting the 'hide on switch' flag, HideMe needs
  96.     to switch another process into the forground in order to switch itself
  97.     out (and thereby make itself invisible).  This routine provides an
  98.     opportunity for your application to select which process will be switched
  99.     into the forground.  */
  100. typedef OSStatus (*SelectNextFrontProcess)(ProcessSerialNumber *myPSN, ProcessSerialNumber *targetPSN);
  101.  
  102. /* HideMe hides the current process making it invisible.  Calling this routine
  103.     is the same as calling the 'Hide xxxxxx' command from the application
  104.     menu in the top right corner of the screen.  HideIdleProc is a routine
  105.     of type EventIdleProc that is called by HideMe while it is waiting for the
  106.     ProcessManager to switch processes in and out of the forground, and
  107.     GetNextP is a routine of type SelectNextFrontProcess that is used by
  108.     HideMe to select the process that is to be moved into the forground
  109.     when it is hidden.  */
  110. OSStatus HideMe(EventIdleProc HideIdleProc, SelectNextFrontProcess GetNextP);
  111.  
  112. #endif
  113.